// pages/course/course.js
const app = getApp()

Page({

    data: {
        isteacher: true,
        inputShowed: false,
        inputVal: ""
    },
    showInput: function () {
        this.setData({
            inputShowed: true
        });
    },
    hideInput: function () {
        this.setData({
            inputVal: "",
            inputShowed: false
        });
    },
    clearInput: function () {
        this.setData({
            inputVal: ""
        });
    },
    inputTyping: function (e) {
        this.setData({
            inputVal: e.detail.value
        });
    },
    inputSearch: function(e){
        console.log('携带数据为：', e.detail.value)
    },

    onLoad: function (options) {
        let course = this;
        let userstatus = app.globalData.userstatus;
        let userId = app.globalData.userId;
        // console.log(userstatus);
        if(userstatus == 0){
            this.setData({
                isteacher:false,
            })
        }
        wx.request({
            url: 'http://localhost/public/course/course/courselist',
            data: {
                userstatus:userstatus,
                userId:userId
            },
            header: {'content-type':'application/json'},
            method: "GET",
            success: ({data}) => {
                console.log(data)
                course.setData({
                    data:data,
                })
            },
        })
    }
})